<!--
  收文->退来文单位
-->
<template>
  <view>
    <van-popup v-model="showCompo" closeable round position="bottom" :style="{ height: '40%' }"
               @click-close-icon="toClose" @click-overlay="toClose">
      <van-row type="flex" justify="center">
        <van-col offset="3" span="8">
          <van-cell value="退来文单位" />
        </van-col>
      </van-row>
      <van-form @submit="onSubmit">
        <van-field v-model="tlwReason" rows="3" required autosize label="退文原因" type="textarea" placeholder="请输入退文原因" />
        <view class="css">
          <van-row type="flex" justify="space-around">
            <van-col span="10">
              <van-button type="info" round plain hairline block @click.prevent="toClose">取消</van-button>
            </van-col>
            <van-col span="10">
              <van-button type="info" round block  native-type="onSubmit">确定</van-button>
            </van-col>
          </van-row>
        </view>

      </van-form>
    </van-popup>
  </view>
</template>

<script>
export default {
  components: {},
  props: {
    showTlwdw: {
      type: Boolean,
      default: false
    },
    paramObject:{
      type: Object
    }
  },
  data() {
    return {
      showCompo:false,  // 组件是否显示
      proInstId: '',
      tlwReason: '',    // 退文原因
    };
  },
  mounted() {

  },
  watch: {
    showTlwdw(val){
      this.showCompo = val
    },
    paramObject: {
      handler(newValue, oldValue) {
        if(JSON.stringify(newValue) != "{}"){
          this.proInstId = newValue.proInstId;
        }
      },
      immediate: true,
      deep: true
    },
  },
  methods: {
    onSubmit() {
      if(this.util.isEmpty(this.tlwReason)){
        this.$toast("请输入退文原因");
        return false;
      }
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/sw/tuiwen`),
        method: 'post',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
        }),
        data: this.$http.adornData({
          "proInstId": this.proInstId,
          "tuiwenyijian": this.tlwReason,
          "tuiwen": "1"
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.$emit('refreshBtnGroup',true);
          this.$toast('退文成功');
        }
      })
    },
    toClose() {
      this.$emit('closeTlwdw', this.showRecords);
    },
  },
};
</script>

<style scoped>
.css {
  text-align: center;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 3%;
}

.van-cell__title {
  min-width: 50%;

span {
  display: inline-block;
  text-align: left;
  word-break: break-all;
}
}

/deep/ .van-field__control {
  font-size: 14px;
  color: #969799;
}
</style>
